{% extends 'TopxiaWebBundle:CourseManage:layout.html.twig' %}

{% block title %}{{ '基本信息'|trans }} - {{ parent() }}{% endblock %}

{% set side_nav = 'base' %}
{% set script_controller = 'course-manage/base' %}
{% set script_arguments = {
categoryUrl: path('category_all'),
tagMatchUrl: path('tag_match'),
locationUrl: path('location_all'),
isCoursePublished: course.status,
} %}
{% block main %}

  <div class="panel panel-default panel-col">
    <div class="panel-heading">{{ '基本信息'|trans }}</div>
    <div class="panel-body">
      <form class="form-horizontal" id="course-form" method="post">

        {{ web_macro.flash_messages() }}

        <div class="form-group">
          <label class="col-md-2 control-label">{{ '标题'|trans }}</label>
          <div class="col-md-8 controls">
            <input type="text" id="course_title" name="title" required="required" class="form-control"
                   value="{{ course.title|default('') }}">
            <div class="help-block" style="display:none;"></div>
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">{{ '副标题'|trans }}</label>
          <div class="col-md-8 controls">
            <textarea id="course_subtitle" name="subtitle" required="required"
                      class="form-control">{{ course.subtitle|default('') }}</textarea>
            <div class="help-block" style="display:none;"></div>
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">{{ '标签'|trans }}</label>
          <div class="col-md-8 controls">
            <input type="text" id="course_tags" name="tags" required="required" class="width-full select2-offscreen"
                   tabindex="-1" value="{{ tags|join(',') }}"
                   data-explain="{{ '用于按标签搜索课程、相关课程的提取等，由网校管理员后台统一管理'|trans }}">
            <div class="help-block">{{ '用于按标签搜索课程、相关课程的提取等，由网校管理员后台统一管理'|trans }}</div>
          </div>
        </div>

        {% if course.type == 'live' %}

          <div class="form-group">
            <label class="col-md-2 control-label"
                   for="maxStudentNum-field">课程人数</label>
            <div class="col-md-10 controls">
              <input type="text" id="maxStudentNum-field" name="maxStudentNum"
                     class="form-control width-input width-input-large" value="{{ course.maxStudentNum|default(20) }}"
                     data-live-capacity-url="{{ path('live_capacity',{id:course.id}) }}"> {{ '人'|trans }}
            </div>
            <div class="col-md-offset-2 col-md-10 js-course-rule">
              <p class="alert-warning"></p>
              <a href="{{path('content_course_rule')}}" target="_blank">【查看直播课程细则】</a>
            </div>
          </div>

        {% endif %}

        <div class="form-group">
          <label class="col-md-2 control-label">{% if setting('default.user_name') %}{{ setting('default.user_name')|default('学员'|trans) }}{% else %}{{ '学员'|trans }}{% endif %}{{ '有效期'|trans }}</label>
          <div class="col-md-8 controls radios">
            {% if course.status == 'published' %}
              <input type="hidden" name="expiryMode" value="{{ course.expiryMode }}">
              {{ radios('expiryMode', {'date':'截止日期'|trans, 'days':'有效期天数'|trans,'none':'无'|trans}, course.expiryMode|default('none'), 'disabled') }}
            {% else %}
              {{ radios('expiryMode', {'date':'截止日期'|trans, 'days':'有效期天数'|trans,'none':'无'|trans}, course.expiryMode|default('none')) }}
            {% endif %}
            <div class="help-block">{{ '已发布课程无法修改有效期方式，如需要修改，请关闭课程后再设置；有效期变更，不影响已经加入课程的学员。'|trans }}</div>
          </div>
        </div>
        <div class="form-group expiry-day-js {% if course.expiryMode|default('none') == 'none' %} hidden {% endif %}">
          <label class="col-md-2 control-label"></label>
          <div class="col-md-8 controls">
            <input type="text" id="course_expiryDay" name="expiryDay" required="required" value="{% if course.expiryMode|default('none') == 'date' %}{{ course.expiryDay|date('Y-m-d') }}{% else %}{{ course.expiryDay }}{% endif %}"
                   class="form-control width-input width-input-large" > <span
                {% if course.expiryMode|default('none') != 'days' %}class="hidden" {% endif %}>{{ '天'|trans }} </span>
            {% set date_help = '设置该值后，%user_name%只能在截止日期前进行课程的学习，系统默认会在截止时间前10天提醒学员。'|trans({'%user_name%': setting('default.user_name')|default('学员'|trans)}) %}
            {% set days_help = '设置该值后，%user_name%学员只能在有效天数内进行课程的学习，系统默认会在有效期前10天提醒学员。'|trans({'%user_name%': setting('default.user_name')|default('学员'|trans)}) %}
            <div class="help-block" data-date="{{ date_help }}" data-days="{{ days_help }}">
              {% if course.expiryMode|default('none') == 'date' %}  {{ date_help }}{% elseif  course.expiryMode|default('none') == 'days' %}{{ days_help }} {% endif %}
            </div>{#即有效期为N天，则只能学习N天，即有效期至yyyy-mm-dd，则只能学习至yyyy-mm-dd 即有效期为N天，则只能学习N天，#}
          </div>
        </div>
        {% if course.type == 'normal' %}
          <div class="form-group">
            <label class="col-md-2 control-label">{{ '连载状态'|trans }}</label>
            <div class="col-md-8 controls radios">
              {{ radios('serializeMode', {'none':'非连载课程'|trans, 'serialize':'更新中'|trans, 'finished':'已完结'|trans}, course.serializeMode|default('none') ) }}
            </div>
          </div>
        {% endif %}

        {% if setting('magic.lesson_watch_limit') %}
          <div class="form-group">
            <label class="col-md-2 control-label">{{ '视频观看时间限制'|trans }}</label>
            <div class="col-md-8 controls">
              <input type="text"  name="watchLimit" required="required"
                     class="form-control width-input width-input-large"
                     value="{{ course.watchLimit }}"> {{ '倍单视频总时长'|trans }}
              <div class="help-block">{{ '0表示不限制。'|trans }}</div>
            </div>
          </div>
        {% endif %}

        {% if setting('magic.buy_before_approval') %}
          <div class="form-group">
            <label class="col-md-2 control-label">{{ '实名认证'|trans }}</label>
            <div class="col-md-8 controls radios">
              {{ radios('approval', {'1':'是'|trans, '0':'否'|trans}, course.approval ) }}
              <div class="help-block">{{ '设置该值后，学员购买课程前，必须先去申请实名认证。'|trans }}</div>
            </div>
          </div>
        {% endif %}

        <div class="form-group">
          <label class="col-md-2 control-label">{{ '分类'|trans }}</label>
          <div class="col-md-8 controls">
            <select id="course_categoryId" name="categoryId" required="required"
                    class="form-control width-input width-input-large">
              {{ select_options(category_choices('course'), course.categoryId, '分类'|trans) }}
            </select>
            <div class="help-block" style="display:none;"></div>
          </div>
        </div>

        {% include 'OrgBundle:Org:org-tree-select.html.twig' with {orgCode : course.orgCode, inputClass: 'width-input width-input-large'} %}

        {% if course.type == 'live' %}
          <div id="live-plugin-url" class="form-group hidden">
            <div class="col-md-offset-2 col-md-8 controls">
              <a href="" target="_blank">{{ '直播“桌面分享”插件下载'|trans }}</a>
            </div>
          </div>
        {% endif %}
        <div class="form-group">
          <div class="col-md-offset-2 col-md-8 controls">
            <button class="btn btn-fat btn-primary" id="course-create-btn" type="submit">{{ '保存'|trans }}</button>
          </div>
        </div>

        <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">

      </form>
    </div>
  </div>

{% endblock %}



